﻿Public Class LoaiHangDAO
    Public Shared Function LoadLoaiHang() As DataTable
        Dim dt As DataTable = Nothing
        Dim strSQL As String = "select * from LoaiHang"
        Dim dp As DataProvider = New DataProvider()
        dt = dp.ExecuteQuery(strSQL)
        Return dt
    End Function
    Public Shared Sub ThemLoaiHang(ByVal _lh As LoaiHang)
        Dim strSQL As String = "insert into LoaiHang(lh_Loai) values ('" & _lh.m_strLoai & "')"
        Dim dp As DataProvider = New DataProvider()
        dp.ExecuteNonQuery(strSQL)
    End Sub
    Public Shared Function XoaLoaiHang(ByVal _lh As LoaiHang)
        Dim dt As DataTable = Nothing
        Dim strSQL As String = "delete from LoaiHang where lh_ID = " & _lh.m_intID & ""
        Dim dp As DataProvider = New DataProvider()
        dt = dp.ExecuteQuery(strSQL)
        Return dt
    End Function
    Public Shared Sub CapNhatLoaiHang(ByVal _lh As LoaiHang)
        Dim strSQL As String = "UPDATE LoaiHang set lh_Loai = '" & _lh.m_strLoai & "' where lh_ID = " & _lh.m_intID & ""
        Dim dp As DataProvider = New DataProvider()
        dp.ExecuteNonQuery(strSQL)
    End Sub
    Public Shared Function TimKiemLoaiHang(ByVal _lh As LoaiHang)
        Dim dt As DataTable = Nothing
        Dim strSQL As String = "select * from LoaiHang  where lh_Loai like '%" & _lh.m_strLoai & "%'"
        Dim dp As DataProvider = New DataProvider()
        dt = dp.ExecuteQuery(strSQL)
        Return dt
    End Function
End Class
